﻿<Window 
    x:Class="HubbleTelescope.Views.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controller="clr-namespace:HubbleTelescope.Controllers;assembly=HubbleTelescope.Controllers"
    Title="{Binding Title}" Height="350" Width="525">
    
    <!--This hooks up our controller for binding-->
    <Window.DataContext>
        <controller:TelescopeController />
    </Window.DataContext>
    
    <!--This converter just helps us bind a bool to a Visibility-->
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="Converter" />
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <!--Refresh button-->
        <Button HorizontalAlignment="Left" Width="150" Height="30" Command="{Binding Refresh}">Refresh</Button>
        
        <!--List of our planets-->
        <ListView Grid.Row="1" ItemsSource="{Binding Planets}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Planet" DisplayMemberBinding="{Binding Name}" />
                    <GridViewColumn Header="Diameter" DisplayMemberBinding="{Binding Path=Diameter, StringFormat={}{0} KM}" />
                </GridView>
            </ListView.View>      
        </ListView>
        
        <!--Our busy indicator-->
        <TextBlock 
            Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" 
            Text="Please Wait..." Visibility="{Binding IsBusy, Converter={StaticResource Converter}}" />
        
    </Grid>
</Window>
